package com.mconnect.msurvey.model;

import java.io.Serializable;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToMany;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;

import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;

/**
 * Osoba ankietowana
 * @author mc104910
 *
 */
@Entity
@Table(name = "responder")
public class Responder implements Serializable{
	private static final long serialVersionUID = 3824009621759402801L;
	private int id_responder;
	private String firstname;
	private String lastname;
	private int phone;
	private String mail = "nie podano";
	private String confirm = "NIE";
	private int numberOfRecommend;
	private String pesel;
	private String note = "brak";
	private List<ResponderRecommended> recommendedList;
	
	@Id
	@GeneratedValue
	public int getId_responder() {
		return id_responder;
	}
	public void setId_responder(int id_responder) {
		this.id_responder = id_responder;
	}
	
	@ManyToMany(cascade={CascadeType.ALL}, fetch=FetchType.LAZY)
	public List<ResponderRecommended> getRecommendedList() {
		return recommendedList;
	}
	public void setRecommendedList(List<ResponderRecommended> recommendedList) {
		this.recommendedList = recommendedList;
	}
	@Column(name="firstname", length=30)
	public String getFirstname() {
		return firstname;
	}
	public void setFirstname(String firstname) {
		this.firstname = firstname;
	}
	@Column(name="lastname", length=30)
	public String getLastname() {
		return lastname;
	}
	public void setLastname(String lastname) {
		this.lastname = lastname;
	}
	@Column(name="phone", length=9)
	public int getPhone() {
		return phone;
	}
	public void setPhone(int phone) {
		this.phone = phone;
	}
	@Column(name="mail", length=30)
	public String getMail() {
		return mail;
	}
	public void setMail(String mail) {
		if(!mail.isEmpty())
			this.mail = mail;
	}
	@Column(name="confirm", length=20)
	public String getConfirm() {
		return confirm;
	}
	public void setConfirm(String confirm) {
		if(!confirm.isEmpty())
			this.confirm = confirm;
	}
	public int getNumberOfRecommend() {
		return numberOfRecommend;
	}
	public void setNumberOfRecommend(int numberOfRecommend) {
		this.numberOfRecommend = numberOfRecommend;
	}
	@Column(name="pesel", length=11)
	public String getPesel() {
		return pesel;
	}
	public void setPesel(String pesel) {
		this.pesel = pesel;
	}
	@Column(name="note", length=255)
	public String getNote() {
		return note;
	}
	public void setNote(String note) {
		if(!note.isEmpty())
			this.note = note;
	}
	@Override
	public String toString() {
		return "Responder [id_responder=" + id_responder + ", firstname="
				+ firstname + ", lastname=" + lastname + ", phone=" + phone
				+ ", mail=" + mail + ", confirm=" + confirm
				+ ", numberOfRecommend=" + numberOfRecommend + ", pesel="
				+ pesel + ", note=" + note + "]";
	}
	
	
}
